<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        
        let obj = {
            name:'张三',
            age:20
        };

        //1.赋值解构
        // let name = obj.name;
        // let age = obj.age;
        let {name,age} = obj;
        console.log(name,age);

        //2.传参解构
        function sayHi({name,age}){// let {name,age} = obj
            console.log(`大家好，我的名字叫${name},我今年${age}岁了`);
        }

        sayHi( {name:'张三',age:20} )
        
        
    </script>
</body>
</html>